//
//  PostHeader.swift
//  Automobile
//
//  Created by erkebulan elzhan on 9/4/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit

struct PostReklama: Equatable {
    var isTop: Bool = false
    var searchUp: Bool = false
    var special: Bool = false
    var colored: Bool = false
}

final class PostHeader: UIView {
    
    private lazy var cityNameLbl: UILabel = {
        let label = UILabel()
        label.textAlignment = .left
        label.font = UIFont.systemFont(ofSize: 15, weight: .medium)
        label.sizeToFit()
        return label
    }()
    private lazy var likeBtn: UIButton = {
        let button = UIButton()
        button.setImage(UIImage(named: "like")?.withRenderingMode(.alwaysTemplate),
                        for: .normal)
        return button
    }()
    
    public func updateUI (cityName: String, isDark: Bool) {
        self.cityNameLbl.text = cityName
        cityNameLbl.textColor = isDark ? .white : .greyColor
    }
    
    
    init () {
        super.init(frame: .zero)
        self.addViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func addViews() {
        addSubview(likeBtn)
        addSubview(cityNameLbl)
        
        likeBtn.snp.makeConstraints { (make) in
            make.width.height.equalTo(16)
            make.top.equalToSuperview().inset(20)
            make.trailing.equalToSuperview().inset(16)
        }
        
        cityNameLbl.snp.makeConstraints { (make) in
            make.leading.equalToSuperview().offset(16)
            make.trailing.equalTo(likeBtn.snp.leading).offset(-8)
            make.bottom.equalToSuperview().offset(-7)
        }
    }
}
